package com.ruoyi.modules.service.impl;

import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.modules.domain.Unit;
import com.ruoyi.modules.mapper.UnitMapper;
import com.ruoyi.modules.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 字典 业务层处理
 *
 * @author tlgen
 */
@Service
public class UnitServiceImpl implements UnitService
{
    @Autowired
    private UnitMapper UnitMapper;

    /**
     * 根据条件分页查询字典数据
     */
    @Override
    public List<Unit> selectUnitList(Unit Unit)
    {
        return UnitMapper.selectUnitList(Unit);
    }

    @Override
    public List<Unit> selectUnitByUnitName(String unitName) {
        return UnitMapper.selectUnitByUnitName(unitName);
    }


    /**
     * 根据字典数据ID查询信息
     */
    @Override
    public Unit selectUnitById(Long creditId)
    {
        return UnitMapper.selectUnitById(creditId);
    }

    /**
     * 批量删除字典数据信息
     */
    @Override
    public int deleteUnitByIds(Long[] creditIds)
    {
        int row = UnitMapper.deleteUnitByIds(creditIds);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    /**
     * 新增保存字典数据信息
     */
    @Override
    public int insertUnit(Unit Unit)
    {
        int row = UnitMapper.insertUnit(Unit);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    /**
     * 修改保存字典数据信息
     */
    @Override
    public int updateUnit(Unit Unit)
    {
        int row = UnitMapper.updateUnit(Unit);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    @Override
    public boolean updateUnitUploadImage(Long unitId, String unitSignature) {
        return UnitMapper.updateUnitUploadImage(unitId, unitSignature) > 0;
    }

}
